//------------会员中心左侧菜单栏------------
function addisshow(str){
		if(document.getElementById(str).style.display=='block'){
			document.getElementById(str).style.display='none';
		}else{
			document.getElementById(str).style.display='block';
		}
	}

//------------全选/全不选/删除------------
$(function () {
	//全选或全不选
	$("#CheckAll").click(function(){   
    	if(this.checked){   
        	$(".click_checkbox").prop("checked", true);  
    	}else{   
		$(".click_checkbox").prop("checked", false);
    	}   
 	}); 
	
	//设置全选复选框
	$(".click_checkbox").click(function(){
		allchk();
	});
 
	//获取选中选项的值
	$("#getValue").click(function(){
		var valArr = new Array;
        $("#list :checkbox[checked]").each(function(i){
			valArr[i] = $(this).val();
        });
		var vals = valArr.join(',');
      	alert(vals);
    });
}); 
function allchk(){
	var chknum = $(".click_checkbox").size();//选项总个数
	var chk = 0;
	$(".click_checkbox").each(function () {  
        if($(this).prop("checked")==true){
			chk++;
		}
    });
	if(chknum==chk){//全选
		$("#CheckAll").prop("checked",true);
	}else{//不全选
		$("#CheckAll").prop("checked",false);
	}
}
	//删除选中
	$(".click_delectThis").click(function  () {
		if($(this).parents("li").find(".click_checkbox").is(":checked")){
			$(this).parents("li").remove();
		}
	})
	//删除全部
	$("#DeleteAll").click(function  () {
		$("#sysmess_table .click_checkbox").each(function  () {
			if($(this).is(":checked")){
				$(this).parents("li").remove();
			}
		})
	})
	
//------------上传图片------------	
		var flag = 0;  
		//校验表单  
		function checkForm(){  
			var idcard =document.getElementById("servertypename").value;  
			var fileName = $('#uploadPath').val();  
			var check_flag = false;  
			if(idcard==""){  
				alert("类型名称不能为空！");  
			}else if(fileName==""){  
				alert("请上传图标！");  
			}else {  
				if(flag==1)  
					alert("您只能输入GIF,BMP,PNG,JPG,JPEG格式的文件");  
				else if(flag==2)  
					alert("请上传尺寸为108*108的图片！");  
				else  
					check_flag = true;  
			}  
			return check_flag;  
		};  
		//预览图片 
		function previewImage(file, url) {  
			var MAXWIDTH = 108;  
			var MAXHEIGHT = 108;  
			if (file.files && file.files[0]) {  
				var img = document.getElementById(url);  
				img.onload = function() {  
					var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);  
					img.width = rect.width;  
					img.height = rect.height;  
					img.style.marginTop = rect.top + 'px';  
				};  
				var reader = new FileReader();  
				reader.onload = function(evt) {  
					img.src = evt.target.result;  
				};  
				reader.readAsDataURL(file.files[0]);  
			} else {  
				file.select();  
			}  
			getImageSize(document.getElementById("uploadPath"));  
		};  
		// 压缩图片 
		function clacImgZoomParam(maxWidth, maxHeight, width, height) {  
			var param = {  
				width: width,  
				height: height  
			};  
			if (width > maxWidth || height > maxHeight) {  
				rateWidth = width / maxWidth;  
				rateHeight = height / maxHeight;  
				if (rateWidth > rateHeight) {  
					param.width = maxWidth;  
					param.height = Math.round(height / rateWidth);  
				} else {  
					param.width = Math.round(width / rateHeight);  
					param.height = maxHeight;  
				}  
			}  
			return param;  
		};  
		//校验图片尺寸 
		function getImageSize(obj) {  
			var _file = document.getElementById("uploadPath");  
			var i = _file.value.lastIndexOf('.');  
			var len = _file.value.length;  
			var extEndName = _file.value.substring(i + 1, len);  
			var extName = "GIF,BMP,PNG,JPG,JPEG";  
			if (extName.indexOf(extEndName.toUpperCase()) == -1) {  
				alert("您只能输入" + extName + "格式的文件");  
				flag = 1;  
			} else {  
				var url, image;  
				if (obj.files) {  
					if (window.navigator.userAgent.indexOf("MSIE") >= 1) {  
						obj.select();  
						url = document.selection.createRange().text;  
					}  
					url = window.URL.createObjectURL(obj.files[0]);  
				} else {  
					url = obj.value;  
					url = "file:///" + url;  
				}  
				image = new Image();  
				image.src = url;  
				image.onload = function() {  
					if (image.width != 108 || image.height != 108) {  
//						alert("请上传尺寸为108*108的图片！");  
						flag = 2;  
					}else{  
						flag = 0;  
					}  
				};  
			}  
		}